//下面这几个包必须要导入才行 in_app_purchase
import 'package:base_pay/entity/product/IProductDetails.dart';
import 'package:in_app_purchase/in_app_purchase.dart';
import 'package:in_app_purchase_android/billing_client_wrappers.dart';
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
import 'package:in_app_purchase_storekit/in_app_purchase_storekit.dart';
import 'package:in_app_purchase_storekit/store_kit_wrappers.dart';

import 'package:mybase/base/tool/platformUtils/FFPlatform.dart';

class AndroidProductEntity implements IProductDetails {
  GooglePlayProductDetails details;
  String? currencyCode;
  String? price;
  double? rawPrice;
  String? currencySymbol;

  AndroidProductEntity({
    required this.details,
  });


  @override
  String getCurrencySymbol() {
    if (getFreeTry() == true) {
      return currencySymbol??"";
    }

    return details.currencySymbol;
  }

  @override
  String getCurrentCode() {
    if (getFreeTry() == true) {
      return currencyCode??"";
    }

    return details.currencyCode;
  }

  @override
  String getID() {
    return details.id;
  }

  @override
  String getPrice() {
    if (getFreeTry() == true) {
      return price??"";
    }

    return details.price;
  }

  @override
  ProductDetails getProductDetails() {
    return details;
  }

  @override
  double getRawPrice() {
    if (getFreeTry() == true) {
      return rawPrice??0;
    }
    return details.rawPrice;
  }

  @override
  bool? getFreeTry() {
    //details.price == details.currencySymbol;
    return details.rawPrice < 0.00000001 ? true : false;
  }



}
